package com.lyx.es.demo;

import org.apache.http.HttpHost;
import org.apache.http.protocol.HTTP;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.transport.TransportClient;

import java.io.IOException;

/**
 * @author LiuYunXin
 * @create 2022-05-22-22:51
 */
public class ES_Client {
    public static void main(String[] args) throws IOException {
        // TransportClient ES旧版连接方式 8.0+废弃
        // 创建ES客户端
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200, "http"))
        );

        // 关闭ES客户端
        restHighLevelClient.close();
    }
}
